import { resolve } from 'path'
import type { Plugin } from 'vite'
import viteSvgIcons from 'vite-plugin-svg-icons'

export function configSvgIconsPlugin(isBuild: boolean, iconPath: string[]): Plugin {
    let dirs: string[] = []
    iconPath.forEach((path) => {
        dirs.push(resolve(process.cwd(), path))
    })
    const svgIconsPlugin: Plugin = viteSvgIcons({
        iconDirs: dirs,
        svgoOptions: isBuild,
        // default
        symbolId: 'icon-[dir]-[name]'
    })
    return svgIconsPlugin
}
